<template>
  <view class="content">
    <block v-if="item">
      <view class="icon">
        <image :src="this.$store.state.imgBaseUrl + '/join-big-1.png'" v-if="item.status == 0 "></image>
        <image :src="this.$store.state.imgBaseUrl + '/join-big-2.png'" v-if="item.status == 2 || item.status == 3"></image>
        <image :src="this.$store.state.imgBaseUrl + '/store-1.png'" v-if="item.status == 1"></image>
      </view>
      <view class="hint-title">
        {{item.status == 0 ? '信息已经提交审核' : item.statusName}}
      </view>
      <view class="hint-text" v-if="item.status == 0">
        请耐心等待1-2个工作日，我们会尽快为您审核，请留意您的短信或系统通知！为了让您更好地享受我们平台提供给商户的赋能工具，我们强烈建议您同时申请我们的聚合收款码
      </view>
      <view class="hint-text" v-else>
        {{item.remark || ''}}
      </view>
      <view class="footer">
        <block v-if="item.status == 1 || item.status == 0">
          <view class="btn right center" @click="attention">
            关注社区电商公众号
          </view>
        </block>
        <block v-else>
          <view class="btn left" @click="next">
            重新提交
          </view>
          <view class="btn right" @click="attention">
            关注社区电商公众号
          </view>
        </block>
      </view>
      <view>
        <uni-fab
          :pattern="pattern"
          :content="content"
          :horizontal="horizontal"
          :direction="direction"
          @trigger="trigger"
        ></uni-fab>
      </view>
    </block>
  </view>
</template>

<script>
import { findV2ByUserId } from "@/service/certificationReplenish/certificationReplenish.service.js"
import { logoutApi } from '@/service/user/user.service.js'
import uniFab from '@/components/uni-fab/uni-fab.vue';
export default {
  components: {uniFab},
  data () {
    return {
      item: null,
      horizontal: 'right',
      direction: 'horizontal',
      pattern: {
        color: '#FFFFFF',
        backgroundColor: 'rgba(0,0,0,0.5)',
        selectedColor: '#007AFF',
        buttonColor:"#434343"
      },
      content: [
        {
          iconPath: '/static/image/icon/loginout.png', // 图片路径
          text: '安全退出',
          active: false
        }
      ],
      hkdUrl: 'https://mp.weixin.qq.com/mp/profile_ext?action=home&__biz=Mzg2NzIzOTY0Nw==&scene=124#wechat_redirect'
    }
  },
  onShow() {
    this.getcheckResult()
  },
  computed: {
    userInfo () {
      return this.$store.state.userInfo
    }
  },
  methods: {
    attention () {
      window.location.href = this.hkdUrl;
    },
    trigger(e) {
      if (e.index == 0) {
        logoutApi({}, res => {
          if (res.status == 0) {
            uni.showToast({
              title: '登出成功！',
              success: () => {
                setTimeout(function () {
                  uni.clearStorageSync();
                 
                }, 2000);
              }
            })
          }
        }, null, {showErrorMsg: true});
      }
    },
    getcheckResult () {
      findV2ByUserId({}, (res) => {
        if (res.status == 0) {
          if (!res.data) {
            uni.navigateTo({
              url: '/pages/freeStore/index?inviteId=' + this.userInfo.inviteId
            })
          } else {
            this.item = res.data;
            if (res.data.status == 1) {
              uni.showToast({
                title: '审核已通过！',
                duration: 2000,
                success: () => {
                  this.$store.dispatch('getUserInfo').then(res => {
                    setTimeout(() => {
                      uni.switchTab({
                        url: '/pages/index/index'
                      })
                    }, 2000);
                  });
                }
              });
            }
          }
        } else {
          uni.showToast({
            title: res.msg,
            icon: 'none'
          });
        }
      })
    },
    next () {
      if (this.item.status == 0) {
        uni.showToast({
          title: '信息正在审核中...',
          icon: 'none'
        });
      } else if (this.item.status == 1) {
        uni.showToast({
          title: '信息已通过！',
          icon: 'none',
          duration: 2000,
          mask: true,
          success: () => {
            uni.switchTab({
              url: '/pages/index/index'
            });
          }
        });
      } else if (this.item.status == 2) {
        // 审核失败
        uni.redirectTo({
          url: '/pages/freeStore/index?inviteId=' + this.userInfo.inviteId
        });
      } else {
        // 审核驳回
        uni.setStorage({
          key: 'freeStoreInfo',
          data: this.item,
          success: () => {
            uni.redirectTo({
              url: '/pages/freeStore/index?inviteId=' + this.userInfo.inviteId
            });
          }
        })
      }
    }
  }
}
</script>

<style lang="scss" scoped>
image {
  width: 100%;
  height: 100%;
}
.content {
  height: 100vh;
  background-color: #FFFFFF;
  .icon {
    width: 330rpx;
    height: 330rpx;
    margin: 34rpx auto 31rpx;
  }
  .hint-title {
    font-size: 36rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: rgba(51,51,51,1);
    text-align: center;
  }
  .hint-text {
    width: 652rpx;
    text-align: center;
    font-size: 30rpx;
    font-family: PingFang SC;
    font-weight: 500;
    color: rgba(153,153,153,1);
    line-height: 1.5;
    margin: 68rpx auto 0;
  }
  .footer {
    width: 690rpx;
    padding: 20rpx 30rpx;
    display: flex;
    justify-content: space-between;
    position: fixed;
    bottom: 0;
    .btn {
      text-align: center;
      height: 88rpx;
      line-height: 88rpx;
      font-size: 36rpx;
      font-family: PingFang SC;
      border-radius: 4rpx;
      &.left {
        height: 85rpx;
        line-height: 85rpx;
        width: 240rpx;
        color: #999999;
        border: 1px solid #999999;
      }
      &.right {
        width: 430rpx;
        color: #F6DA99;
        background-color: #434343;
      }
      &.center {
        width: 690rpx;
      }
    }
  }
}
</style>
